<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
		<button onclick="showDriveInfo()">showDriveInfo</button>
		<button onclick="writeFile()">writeFile</button>
		<script type="text/javascript">
			/*IE上有效*/
			function showDriveInfo() {
				var fso, drv, s = "";
				fso = new ActiveXObject("Scripting.FileSystemObject");
				drv = fso.GetDrive(fso.GetDriveName("E:\\"));
				s += "E盘:" + " - \n";
				s += "硬盘大小：" + Math.floor(drv.TotalSize / 1024 / 1024 / 1024);
				s += " GB" + "\n";
				s += "硬盘可用空间：" + Math.floor(drv.FreeSpace / 1024 / 1024 / 1024);
				s += " GB" + "\n";
				s += "硬盘可用空间：" + Math.floor(drv.AvailableSpace / 1024 / 1024 / 1024);
				s += " GB" + "\n";
				s += "驱动器盘符：" + drv.DriveLetter + "盘\n";
				s += "驱动器类型：" + drv.DriveType + "\n";
				s += "驱动器的系列码:" + drv.SerialNumber + "\n";
				s += "驱动器的文件系统类型:" + drv.FileSystem + "\n";
				s += "驱动器是否可用:" + drv.IsReady + "\n";
				s += "共享名称:" + drv.ShareName + "\n";
				s += "卷标名称:" + drv.VolumeName + "\n";
				s += "驱动器的路径或者根目录名称:" + drv.Path + "\n";
				s += "驱动器的路径或者根目录名称:" + drv.RootFolder + "\n";
				alert(s);
			}

			function writeFile() {
				var fso, tf;
				fso = new ActiveXObject("Scripting.FileSystemObject");
				// 创建新文件
				tf = fso.CreateTextFile("E:\\testfile.txt", true);
				// 填写数据，并增加换行符
				tf.WriteLine("Testing 1, 2, 3.");
				// 增加3个空行
				tf.WriteBlankLines(3);
				// 填写一行，不带换行符
				tf.Write("我是深情小建.");
				// 关闭文件
				tf.Close();
			}
		</script>
	</body>

</html>